fix: performance issue in interpretability notebooks #1238
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the notebook, the background data should be broadcasted. When the
explain_instances
dataframe (observations to be explained) is in a mid range (50 to 100-ish), Spark will use a unexpected type of join plan, and messes up with the parallelization of the Kernel SHAP sampler, thus creating a performance bottleneck. Broadcasting the background dataset makes Spark respect the partitioning of theexplain_instances
dataframe.These two notebooks both explain only 5 data points, so the performance bottleneck is not obvious. However, if we change 5 to 50, it becomes obvious. But if we further change it 500, Spark uses the intended join plan, and the bottleneck is not triggered.
I thought about forcing the broadcast inside the explainer, but this may create unexpected effect for other scenarios, so I'm hesitant to do so.